///////////////////////////////////////////////////////////////////////////
//
// Spring Engine Source File.
// Copyright (C), Dengtao 2011-2021
// ----------------------------------------------------------------------
// File name:   SfRefObject.h
// Version:     v1.0.0
// Created:     2013/06/15 21:40 by dengtao
// Compilers:   Visual Studio 2008
// Description: 
// ----------------------------------------------------------------------
// History:
//
///////////////////////////////////////////////////////////////////////////

#ifndef _SfRefObject_H_
#define _SfRefObject_H_

#include "SfMemoryObject.h"

namespace Sunflower
{

//////////////////////////////////////////////////////////////////////////
//Summary:
//	base object for reference count.
//////////////////////////////////////////////////////////////////////////
class RefObject : public MemoryObject
{
public:
	//
	//Summary:
	//	constructor.
	RefObject();

	//
	//Summary:
	//	destructor.
	virtual ~RefObject();

	//
	//Summary:
	//	retrieves reference count of RefObject object.
	int GetRefCount() const { return m_RefCount; }

	//
	//Summary:
	//	Increment reference count.
	void IncRefCount();

	//
	//Summary:
	//	decrement reference.
	void Release();

	//
	//Summary:
	//	callback when delete this object.
	//	default implement is delete object.
	virtual void DeleteThis();

private:
	int m_RefCount;
};

#include "SfRefObject.inl"

}

#endif
